home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagn_r.zip / PRINTING.SWG / 0018_Print Spooler Interface.pas < prev    next >
Pascal/Delphi Source File  |  1993-07-16  |  1KB  |  67 lines

  1. Program SPOOLIT;
  2.  
  3. { Example program to demonstrate the PRINT spooler interface }
  4.  
  5. { Define the data structure we need for spooling files }
  6.  
  7. Uses DOS;
  8.  
  9. Type
  10.  
  11.   SpoolRecType = Record
  12.     Priority : Byte;
  13.     Filename : Pointer;
  14.   end;
  15.  
  16. Var
  17.  
  18.   SpoolFile   : PathStr;
  19.   SpoolBuffer : Array[1..70] of char;
  20.   SpoolRec    : SpoolRecType;
  21.   Regs        : Registers;
  22.   SpooledOk   : Boolean;
  23.  
  24. Begin
  25.  
  26.   With Regs do begin
  27.     AX := $100;
  28.     Intr($2F,Regs);
  29.     If AL = 0 then Begin
  30.       WriteLn('PRINT is not loaded.');
  31.       Halt
  32.       end
  33.     end;
  34.  
  35.   { Query user for the name of a file to spool }
  36.  
  37.   Write('Enter the filename to print: ');
  38.   ReadLn(SpoolFile);
  39.  
  40.   If Length(SpoolFile) = 0 then Halt;  {Nothing to do, so quit}
  41.  
  42.   FillChar(SpoolBuffer,SizeOf(SpoolBuffer),0);
  43.  
  44.   Move(SpoolFile[1],SpoolBuffer,Length(SpoolFile));
  45.  
  46.   SpoolRec.Priority := 0;
  47.   SpoolRec.Filename := Addr(SpoolBuffer);
  48.  
  49.   { Send the file on its way }
  50.  
  51.   With Regs do Begin
  52.     AX := $101;
  53.     DS := DSeg;
  54.     DX := Ofs(SpoolRec);
  55.     Intr($2F,Regs);
  56.  
  57.     { Isolate the status fo the spool operation }
  58.  
  59.     SpooledOK := Not ((Flags and 1) = 1);
  60.  
  61.     If SpooledOk then
  62.       WriteLn('Your file has been placed in the queue.')
  63.     else
  64.       WriteLn('Could not spool your file, error code is ',AL)
  65.     end
  66.  
  67. End.